package com.px.plan.service.impl;

import com.px.plan.domain.PlanMarkCoordinate;
import com.px.plan.mapper.PlanMarkCoordinateMapper;
import com.px.plan.service.IPlanMarkCoordinateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 区域协作点记录Service业务层处理
 * 
 * @author WRJ
 * @date 2024-08
 */
@Service
public class PlanMarkCoordinateServiceImpl implements IPlanMarkCoordinateService 
{
    @Autowired
    private PlanMarkCoordinateMapper planMarkCoordinateMapper;

    /**
     * 查询区域协作点记录
     * 
     * @param id 区域协作点记录主键
     * @return 区域协作点记录
     */
    @Override
    public PlanMarkCoordinate selectPlanMarkCoordinateById(Long id)
    {
        return planMarkCoordinateMapper.selectPlanMarkCoordinateById(id);
    }

    /**
     * 查询区域协作点记录列表
     * 
     * @param planMarkCoordinate 区域协作点记录
     * @return 区域协作点记录
     */
    @Override
    public List<PlanMarkCoordinate> selectPlanMarkCoordinateList(PlanMarkCoordinate planMarkCoordinate)
    {
        return planMarkCoordinateMapper.selectPlanMarkCoordinateList(planMarkCoordinate);
    }

    /**
     * 新增区域协作点记录
     * 
     * @param planMarkCoordinate 区域协作点记录
     * @return 结果
     */
    @Override
    public int insertPlanMarkCoordinate(PlanMarkCoordinate planMarkCoordinate)
    {
        return planMarkCoordinateMapper.insertPlanMarkCoordinate(planMarkCoordinate);
    }

    /**
     * 修改区域协作点记录
     * 
     * @param planMarkCoordinate 区域协作点记录
     * @return 结果
     */
    @Override
    public int updatePlanMarkCoordinate(PlanMarkCoordinate planMarkCoordinate)
    {
        return planMarkCoordinateMapper.updatePlanMarkCoordinate(planMarkCoordinate);
    }

    /**
     * 批量删除区域协作点记录
     * 
     * @param ids 需要删除的区域协作点记录主键
     * @return 结果
     */
    @Override
    public int deletePlanMarkCoordinateByIds(Long[] ids)
    {
        return planMarkCoordinateMapper.deletePlanMarkCoordinateByIds(ids);
    }

    /**
     * 删除区域协作点记录信息
     * 
     * @param id 区域协作点记录主键
     * @return 结果
     */
    @Override
    public int deletePlanMarkCoordinateById(Long id)
    {
        return planMarkCoordinateMapper.deletePlanMarkCoordinateById(id);
    }

    @Override
    public List<PlanMarkCoordinate> selectPlanMarkCoordinateByPlanMarkId(Long id) {
        PlanMarkCoordinate pmc = new PlanMarkCoordinate();
        pmc.setMarkId(id);
        List<PlanMarkCoordinate> planMarkCoordinates = planMarkCoordinateMapper.selectPlanMarkCoordinateList(pmc);
        planMarkCoordinates = planMarkCoordinates.stream().sorted(Comparator.comparing(PlanMarkCoordinate::getNumber)).collect(Collectors.toList());
        return planMarkCoordinates;
    }
}
